package com.lagou.dao.mapper;

import com.lagou.dao.pojo.TokenLog;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TokenLogMapper {

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "email", column = "email"),
            @Result(property = "token", column = "token")
    })
    @Select("select * from lagou_token where email = #{email}")
    public List<TokenLog> findUserCodeByEmail(String email);

    @Select("select * from lagou_token where token = #{token}")
    public List<TokenLog> findUserCodeByToken(String token);

    @Insert("insert into lagou_token (email, token) values (#{email}, #{token})")
    public int insertToken(TokenLog tokenLog);

    @Update("update lagou_token set token = #{token} where email = #{email}")
    public int updateToken(TokenLog tokenLog);
}
